import _ from "lodash"
import {noLengthAttrArrayLikeToArray} from "../helper"
interface sheetsItemInterface {
    [key: string]: any,
    data: any,
    index: number,
    name: string
}

interface sheetsInterface {
    [key: string]: sheetsItemInterface
}
const obj: Record<string | number | symbol, any> = {};


//从excel获取第一个sheet的数据 第0个默认是Evaluation Version 第1个是第一个sheet
export const getSheetDatafromExcelParseData = (sheets: sheetsInterface, index = 1) => {
    for (let k in sheets) {
        let item: sheetsItemInterface = sheets[k]
        if (item.index === index) {
            return item.data.dataTable
        }
    }
}



export const makeRowItemByParseExcelItem = (dataItemTempData: any, parseExcelItem: any, itemEnum: any, extraData: any) => {
    let ret = _.cloneDeep(dataItemTempData)
    for (let k in dataItemTempData) {
        if(itemEnum[k] == null) {
            ret[k] = parseExcelItem[k]
        }else{
            ret[k] = parseExcelItem[itemEnum[k]].value 
        }
    }
    ret.children = parseExcelItem.children
    ret.id = parseExcelItem.id
    ret.parentId = parseExcelItem.parentId
    ret.level = parseExcelItem.level
    ret.hasChildren = parseExcelItem.hasChildren
    for (let k in extraData) {
        ret[k] = extraData[k]
    }
    return ret
}
